<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.0.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">


<script id="hexo-configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '7.5.0',
    exturl: false,
    sidebar: {"position":"left","display":"post","offset":12,"onmobile":false},
    copycode: {"enable":false,"show_result":false,"style":null},
    back2top: {"enable":true,"sidebar":false,"scrollpercent":false},
    bookmark: {"enable":false,"color":"#222","save":"auto"},
    fancybox: false,
    mediumzoom: false,
    lazyload: false,
    pangu: false,
    algolia: {
      appID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    },
    localsearch: {"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},
    path: '',
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    translation: {
      copy_button: '复制',
      copy_success: '复制成功',
      copy_failure: '复制失败'
    },
    sidebarPadding: 40
  };
</script>

  <meta name="description" content="选择结构：也叫分支结构，是指在算法中通过对条件的判断，根据条件是否成立而选择不同流向的算法结构。">
<meta name="keywords" content="计算机,语言,python,结构">
<meta property="og:type" content="article">
<meta property="og:title" content="程序基本结构">
<meta property="og:url" content="https:&#x2F;&#x2F;chasemyking.github.io&#x2F;2019&#x2F;12&#x2F;09&#x2F;%E7%A8%8B%E5%BA%8F%E5%9F%BA%E6%9C%AC%E7%BB%93%E6%9E%84&#x2F;index.html">
<meta property="og:site_name" content="chasemyking">
<meta property="og:description" content="选择结构：也叫分支结构，是指在算法中通过对条件的判断，根据条件是否成立而选择不同流向的算法结构。">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="https:&#x2F;&#x2F;chasemyking.github.io&#x2F;images&#x2F;程序的三种结构.png">
<meta property="og:image" content="https:&#x2F;&#x2F;chasemyking.github.io&#x2F;images&#x2F;文件数据累加.png">
<meta property="og:image" content="https:&#x2F;&#x2F;chasemyking.github.io&#x2F;images&#x2F;date1.png">
<meta property="og:updated_time" content="2019-12-10T03:41:32.031Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https:&#x2F;&#x2F;chasemyking.github.io&#x2F;images&#x2F;程序的三种结构.png">

<link rel="canonical" href="https://chasemyking.github.io/2019/12/09/%E7%A8%8B%E5%BA%8F%E5%9F%BA%E6%9C%AC%E7%BB%93%E6%9E%84/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome: false,
    isPost: true,
    isPage: false,
    isArchive: false
  };
</script>

  <title>程序基本结构 | chasemyking</title>
  


  <script>
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?0e2a4e5bd5a98fcd51a1d8d5405bdfb8";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-meta">

    <div>
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">chasemyking</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
  </div>

  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>
</div>


<nav class="site-nav">
  
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
  </ul>

</nav>
</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content">
            

  <div class="posts-expand">
      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block " lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://chasemyking.github.io/2019/12/09/%E7%A8%8B%E5%BA%8F%E5%9F%BA%E6%9C%AC%E7%BB%93%E6%9E%84/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/chasemyking.jpg">
      <meta itemprop="name" content="chasemyking">
      <meta itemprop="description" content="我永远喜欢艾斯德斯！">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="chasemyking">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          程序基本结构
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2019-12-09 19:13:09" itemprop="dateCreated datePublished" datetime="2019-12-09T19:13:09+08:00">2019-12-09</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2019-12-10 11:41:32" itemprop="dateModified" datetime="2019-12-10T11:41:32+08:00">2019-12-10</time>
              </span>

          
            <span id="/2019/12/09/%E7%A8%8B%E5%BA%8F%E5%9F%BA%E6%9C%AC%E7%BB%93%E6%9E%84/" class="post-meta-item leancloud_visitors" data-flag-title="程序基本结构" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span><br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>2.4k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>2 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>选择结构：<br>也叫分支结构，是指在算法中通过对条件的判断，根据条件是否成立而选择不同流向的算法结构。 </p>
<a id="more"></a> 
<p>循环结构：<br>是指在一定条件下反复执行某部分代码的操作，是程序设计中最能发挥计算机特长的程序结构。<br><img src="/images/程序的三种结构.png" class="full-iamge"/><br>简单分支结构：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"><span class="keyword">if</span>(条件表达示)：</span><br><span class="line">    执行语句</span><br><span class="line"><span class="keyword">if</span>（条件表达示）：</span><br><span class="line">    执行语句</span><br></pre></td></tr></table></figure>

<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">main</span><span class="params">()</span>:</span></span><br><span class="line">    <span class="comment">#str_num=input("请输入污染指数：（1—100）：")</span></span><br><span class="line">    <span class="comment">#date=int(str_num)</span></span><br><span class="line">    date=eval(input(<span class="string">"输入污染指数："</span>))</span><br><span class="line">    <span class="keyword">if</span> date&gt;=<span class="number">75</span>:</span><br><span class="line">        print(<span class="string">"空气污染严重！"</span>)</span><br><span class="line">    <span class="keyword">if</span> date&lt;=<span class="number">25</span>:</span><br><span class="line">        print(<span class="string">"空气优良！"</span>)</span><br><span class="line">    <span class="keyword">if</span> <span class="number">25</span>&lt;date&lt;<span class="number">75</span>:</span><br><span class="line">        print(<span class="string">"空气状况良好！"</span>)</span><br><span class="line"></span><br><span class="line">main()</span><br></pre></td></tr></table></figure>
<p>注：程序中，eval（）函数的意思是将输入的input()字符串执行为表达示，也可将其当成转化为int类型，但其中还是有很大的差别的。<br>列如：在输入时，如果你输入的是50+25，eval（）会将其当成算数表达示，并计算出结果。<br>二分支语句：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">if</span>(条件表达式)：</span><br><span class="line">    执行语句</span><br><span class="line"><span class="keyword">else</span>：</span><br><span class="line">    执行语句</span><br></pre></td></tr></table></figure>
<p>多分支语句：<br>(1)嵌套</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">if</span>(条件表达式)：</span><br><span class="line">    执行语句</span><br><span class="line"><span class="keyword">else</span>：</span><br><span class="line">    <span class="keyword">if</span>(条件表达式)：</span><br><span class="line">    执行语句</span><br><span class="line">    <span class="keyword">else</span>：</span><br><span class="line">    执行语句</span><br></pre></td></tr></table></figure>
<p>列：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> math</span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">main</span><span class="params">()</span>:</span></span><br><span class="line">    print(<span class="string">"这是一个标准的一元二次方程计算程序！"</span>)</span><br><span class="line">    a,b,c=eval(input(<span class="string">"输入一元二次方程的a，b，c值："</span>))</span><br><span class="line">    date=b*b<span class="number">-4</span>*a*c</span><br><span class="line">    <span class="keyword">if</span> (date&lt;<span class="number">0</span>):</span><br><span class="line">        print(<span class="string">"一元二次方程没有解！"</span>)</span><br><span class="line">    <span class="keyword">else</span>:</span><br><span class="line">        <span class="keyword">if</span> (date==<span class="number">0</span>):</span><br><span class="line">            root=-b/(<span class="number">2</span>*a)</span><br><span class="line">            print(<span class="string">"该方程只有一个根root=%f"</span>%root)</span><br><span class="line">        <span class="keyword">else</span>:</span><br><span class="line">            discroot=math.sqrt(date)</span><br><span class="line">            root1=(-b+discroot)/<span class="number">2</span>*a</span><br><span class="line">            root2=(-b+discroot)/<span class="number">2</span>*a</span><br><span class="line">            print(<span class="string">"一元二次方程的两个根分别是root1=%d,root2=%f"</span>%(root1,root2))</span><br><span class="line">main()</span><br></pre></td></tr></table></figure>
<p>(2)if-elif-else<br>例：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> math</span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">main</span><span class="params">()</span>:</span></span><br><span class="line">    print(<span class="string">"这是一个标准的一元二次方程计算程序！"</span>)</span><br><span class="line">    a,b,c=eval(input(<span class="string">"输入一元二次方程的a，b，c值："</span>))</span><br><span class="line">    date=b*b<span class="number">-4</span>*a*c</span><br><span class="line">    <span class="keyword">if</span> (date&lt;<span class="number">0</span>):</span><br><span class="line">        print(<span class="string">"一元二次方程没有解！"</span>)</span><br><span class="line">    <span class="keyword">elif</span> (date==<span class="number">0</span>):</span><br><span class="line">        root=-b/(<span class="number">2</span>*a)</span><br><span class="line">        print(<span class="string">"该方程只有一个根root=%f"</span>%root)</span><br><span class="line">    <span class="keyword">else</span>:</span><br><span class="line">        discroot=math.sqrt(date)</span><br><span class="line">        root1=(-b+discroot)/<span class="number">2</span>*a</span><br><span class="line">        root2=(-b+discroot)/<span class="number">2</span>*a</span><br><span class="line">        print(<span class="string">"一元二次方程的两个根分别是root1=%d,root2=%f"</span>%(root1,root2))</span><br><span class="line">main()</span><br></pre></td></tr></table></figure>

<p>异常处理机制： </p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">try</span>：</span><br><span class="line">    (执行语句)</span><br><span class="line">    <span class="keyword">break</span></span><br><span class="line"><span class="keyword">except</span>(错误类型<span class="number">1</span>)：</span><br><span class="line">    （执行语句）</span><br><span class="line"><span class="keyword">except</span>(错误类型<span class="number">2</span>)：</span><br><span class="line">    （执行语句）</span><br><span class="line">    .....</span><br></pre></td></tr></table></figure>
<p>计算机判断try中的执行语句，如果没有异常则继续运行下面的语句，如果发生错误则从except中查找错误类型。<br>列：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">main</span><span class="params">()</span>:</span></span><br><span class="line">    <span class="keyword">while</span> <span class="literal">True</span>:</span><br><span class="line">        <span class="keyword">try</span>:</span><br><span class="line">            x=int(input(<span class="string">"请输入一个数："</span>))</span><br><span class="line">            <span class="keyword">break</span></span><br><span class="line">        <span class="keyword">except</span> ValueError:</span><br><span class="line">            print(<span class="string">"你输入的数不正确！再输一次！"</span>)</span><br><span class="line">main()</span><br></pre></td></tr></table></figure>
<p>try语句和else以及finally关键字：  </p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">try</span>：</span><br><span class="line">    (执行语句)</span><br><span class="line">    <span class="keyword">break</span></span><br><span class="line"><span class="keyword">except</span>(错误类型<span class="number">1</span>)：</span><br><span class="line">    （执行语句）</span><br><span class="line"><span class="keyword">except</span>(错误类型<span class="number">2</span>)：</span><br><span class="line">    （执行语句）</span><br><span class="line"><span class="keyword">else</span>（）：</span><br><span class="line">    （执行语句）</span><br><span class="line"><span class="keyword">finally</span>（）：</span><br><span class="line">    （执行语句）</span><br></pre></td></tr></table></figure>
<p>注：else和finally是非必须项，是可选的。但else必须出现在finally之前，而finally必须出现在整个语句之后。<br>注：try语句的执行时，如果有异常，则执行相应的错误语句；如果无异常产生，则执行else语句。finally语句的意思是无论有没有错误都要执行。<br>python标准异常（部分）：</p>
<table>
<thead>
<tr>
<th>异常名称</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>ArithmeticError</td>
<td>所有数值计算错误的基类</td>
</tr>
<tr>
<td>FloatingPointError</td>
<td>浮点计算错误</td>
</tr>
<tr>
<td>OverflowError</td>
<td>数值运算超出最大限制</td>
</tr>
<tr>
<td>ZeroDivisionError</td>
<td>除(或取模)零 (所有数据类型)</td>
</tr>
<tr>
<td>IOError</td>
<td>输入/输出操作失败</td>
</tr>
<tr>
<td>NameError</td>
<td>未声明/初始化对象 (没有属性)</td>
</tr>
<tr>
<td>SyntaxError</td>
<td>Python 语法错误</td>
</tr>
<tr>
<td>IndentationError</td>
<td>缩进错误</td>
</tr>
<tr>
<td>TypeError</td>
<td>对类型无效的操作</td>
</tr>
<tr>
<td>ValueError</td>
<td>传入无效的参数</td>
</tr>
<tr>
<td>SyntaxWarning</td>
<td>可疑的语法的警告</td>
</tr>
</tbody></table>
<p><a href="https://www.runoob.com/python/python-exceptions.html" target="_blank" rel="noopener">详细异常展示：</a></p>
<p>循环结构：<br>for循环结构：循环遍历整个序列的值。</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">for</span> &lt;var&gt; <span class="keyword">in</span> &lt;sequence&gt;:</span><br><span class="line">    &lt;body&gt;</span><br></pre></td></tr></table></figure>
<p>例：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">main</span><span class="params">()</span>:</span></span><br><span class="line">    n=eval(input(<span class="string">"请输入类累加数的个数："</span>))</span><br><span class="line">    sum=<span class="number">0.0</span></span><br><span class="line">    <span class="keyword">for</span> i <span class="keyword">in</span> range(n):</span><br><span class="line">        date=eval(input(<span class="string">"请输入数据："</span>))</span><br><span class="line">        sum=date+sum</span><br><span class="line">    print(<span class="string">"平均值是："</span>,sum/n)</span><br><span class="line">main()</span><br></pre></td></tr></table></figure>

<p>条件循环：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">while</span>&lt;conditon&gt;:<span class="comment">#condition是布尔表达示</span></span><br><span class="line">    &lt;body&gt;</span><br></pre></td></tr></table></figure>
<p>break：结束所有循环，执行主体程序。<br>continue:结束本次循环。</p>
<p>读取文件数据，求平均:<br>程序：<br><img src="\images\文件数据累加.png" width="100%" class="full-image"/><br>文件：  </p>
<td><img src="\images\date1.png" width="100%" class="full-image"/>

<p>布尔操作：<br>and，or，not<br>优先及：not&gt;and&gt;or</p>

    </div>

    
    
    
      
        <div class="reward-container">
  <div>这么精彩！不赞一个吗！^_^</div>
  <button disable="enable" onclick="var qr = document.getElementById(&quot;qr&quot;); qr.style.display = (qr.style.display === 'none') ? 'block' : 'none';">
    打赏
  </button>
  <div id="qr" style="display: none;">
      
      <div style="display: inline-block;">
        <img src="/images/wechatpay.png" alt="chasemyking 微信支付">
        <p>微信支付</p>
      </div>
      
      <div style="display: inline-block;">
        <img src="/images/alipay.jpg" alt="chasemyking 支付宝">
        <p>支付宝</p>
      </div>

  </div>
</div>


      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/%E8%AE%A1%E7%AE%97%E6%9C%BA/" rel="tag"># 计算机</a>
              <a href="/tags/%E8%AF%AD%E8%A8%80/" rel="tag"># 语言</a>
              <a href="/tags/python/" rel="tag"># python</a>
              <a href="/tags/%E7%BB%93%E6%9E%84/" rel="tag"># 结构</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-next post-nav-item">
                <a href="/2019/12/08/%E7%AE%80%E5%8D%95hexo%E8%BF%90%E7%94%A8/" rel="next" title="简单hexo运用">
                  <i class="fa fa-chevron-left"></i> 简单hexo运用
                </a>
            </div>

            <span class="post-nav-divider"></span>

            <div class="post-nav-prev post-nav-item">
                <a href="/2019/12/10/%E5%87%BD%E6%95%B0/" rel="prev" title="函数">
                  函数 <i class="fa fa-chevron-right"></i>
                </a>
            </div>
          </div>
      </footer>
    
  </article>
  
  
  

  </div>


          </div>
          

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <img class="site-author-image" itemprop="image" alt="chasemyking"
    src="/images/chasemyking.jpg">
  <p class="site-author-name" itemprop="name">chasemyking</p>
  <div class="site-description" itemprop="description">我永远喜欢艾斯德斯！</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">16</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">3</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">19</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/chasemyking/chasemyking.github.io" title="GitHub &amp;rarr; https:&#x2F;&#x2F;github.com&#x2F;chasemyking&#x2F;chasemyking.github.io" rel="noopener" target="_blank"><i class="fa fa-fw fa-github"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="/mailto:cangtiandadi2016@outlook.com" title="E-Mail &amp;rarr; mailto:cangtiandadi2016@outlook.com" rel="noopener" target="_blank"><i class="fa fa-fw fa-envelope"></i>E-Mail</a>
      </span>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">chasemyking</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
    <span title="站点总字数">59k</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
    <span title="站点阅读时长">54 分钟</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> 强力驱动 v4.0.0
  </div>
  <span class="post-meta-divider">|</span>
  <div class="theme-info">主题 – <a href="https://theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Gemini</a> v7.5.0
  </div>

        






  <script>
  function leancloudSelector(url) {
    return document.getElementById(url).querySelector('.leancloud-visitors-count');
  }
  if (CONFIG.page.isPost) {
    function addCount(Counter) {
      var visitors = document.querySelector('.leancloud_visitors');
      var url = visitors.getAttribute('id').trim();
      var title = visitors.getAttribute('data-flag-title').trim();

      Counter('get', `/classes/Counter?where=${JSON.stringify({ url })}`)
        .then(response => response.json())
        .then(({ results }) => {
          if (results.length > 0) {
            var counter = results[0];
            Counter('put', '/classes/Counter/' + counter.objectId, { time: { '__op': 'Increment', 'amount': 1 } })
              .then(response => response.json())
              .then(() => {
                leancloudSelector(url).innerText = counter.time + 1;
              })
              .catch(error => {
                console.log('Failed to save visitor count', error);
              })
          } else {
              leancloudSelector(url).innerText = 'Counter not initialized! More info at console err msg.';
              console.error('ATTENTION! LeanCloud counter has security bug, see how to solve it here: https://github.com/theme-next/hexo-leancloud-counter-security. \n However, you can still use LeanCloud without security, by setting `security` option to `false`.');
            
          }
        })
        .catch(error => {
          console.log('LeanCloud Counter Error', error);
        });
    }
  } else {
    function showTime(Counter) {
      var visitors = document.querySelectorAll('.leancloud_visitors');
      var entries = [...visitors].map(element => {
        return element.getAttribute('id').trim();
      });

      Counter('get', `/classes/Counter?where=${JSON.stringify({ url: { '$in': entries } })}`)
        .then(response => response.json())
        .then(({ results }) => {
          if (results.length === 0) {
            document.querySelectorAll('.leancloud_visitors .leancloud-visitors-count').forEach(element => {
              element.innerText = 0;
            });
            return;
          }
          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.url;
            var time = item.time;
            leancloudSelector(url).innerText = time;
          }
          for (var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = leancloudSelector(url);
            if (element.innerText == '') {
              element.innerText = 0;
            }
          }
        })
        .catch(error => {
          console.log('LeanCloud Counter Error', error);
        });
    }
  }

  fetch('https://app-router.leancloud.cn/2/route?appId=F1yOARDU4POU2Iuir3vgWVrB-gzGzoHsz')
    .then(response => response.json())
    .then(({ api_server }) => {
      var Counter = (method, url, data) => {
        return fetch(`https://${api_server}/1.1${url}`, {
          method: method,
          headers: {
            'X-LC-Id': 'F1yOARDU4POU2Iuir3vgWVrB-gzGzoHsz',
            'X-LC-Key': 'ADyvs9fVUxLnHglgfNMBDNlr',
            'Content-Type': 'application/json',
          },
          body: JSON.stringify(data)
        });
      };
      if (CONFIG.page.isPost) {
        const localhost = /http:\/\/(localhost|127.0.0.1|0.0.0.0)/;
        if (localhost.test(document.URL)) return;
        addCount(Counter);
      } else if (document.querySelectorAll('.post-title-link').length >= 1) {
        showTime(Counter);
      }
    });
  </script>






        
      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>
<script src="/js/utils.js"></script><script src="/js/motion.js"></script>
<script src="/js/schemes/pisces.js"></script>
<script src="/js/next-boot.js"></script>



  
















  

  

<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"debug":false,"model":{"jsonPath":"/live2dw/assets/assets/miku.model.json"},"display":{"position":"right","width":150,"height":300},"mobile":{"show":true},"react":{"opacity":0.7},"log":false});</script></body>
</html>
